//
//  main.swift
//  C150805_lazy
//
//  Created by yao_yu on 15/8/5.
//  Copyright © 2015年 yao_yu. All rights reserved.
//

import Foundation

print("Hello, World!")

class CTest {
    var a:Int = 0 {
        didSet {
            print("a = \(a)")
        }
    }
    //lazy只进行一次赋值,后期还是可以被修改
    lazy var b:Int = {
        print("lazy set b")
        return self.a
    }()
}

let t1 = CTest()

t1.a = 2
assert(t1.a == t1.b)
t1.a = 3
assert(t1.a != t1.b)

t1.b = 33
print(t1.b)